package com.atguigu.chapter05.Transform;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

import java.util.Arrays;
import java.util.List;

/**
 * TODO
 *
 * @author cjp
 * @version 1.0
 * @date 2021/3/3 15:29
 */
public class Flink04_Filter {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        // TODO Transform  -  Filter ： 过滤,true留下，false丢弃
        DataStreamSource<Integer> inputDS = env.fromElements(1, 2, 3, 4, 5, 6, 7, 8);

        inputDS
//                .filter(new FilterFunction<Integer>() {
//                    @Override
//                    public boolean filter(Integer value) throws Exception {
//                        return value % 2 == 0;
//                    }
//                })
                .filter(value -> value % 2 == 0)
                .print();

        env.execute();
    }
}
